﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProductIntory.Domains;
using ProductIntory.ErrorCodes;
using ProductIntory.Read.Apis.Application.Command.ProductInspectionCommands;
using ProductIntory.Read.Apis.Application.Command.ProductsCommands;

namespace ProductIntory.Read.Apis.Controllers
{
    [Route("api/[controller]/[action]")]

    [ApiController]
    public class ProductIntoryController : ControllerBase
    {
        IMediator mediator;
        //ts
        public ProductIntoryController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        [HttpGet]
        public async Task<ApiPaging<List<ProductInspection>>> ShowProductsInspection( [FromQuery] ShowProductInspectionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }


  
        [HttpGet]
        public async Task<ApiResult<int>> DeleteProductsInspection( [FromQuery] DeletProductInspectionCommands request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateProductsInspection (UpdateProductInspectionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<List<ProductInspection>>> FirstProductInspection([FromQuery] FirstProductInspectionCommands request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
